<template>
  <el-container>
    <el-header>
      <div class="buttons-header">
        <div></div>
        <div class="buttons">
          <!-- <el-button @click="share">分享</el-button> -->
          <!-- <el-button @click="close">关闭</el-button> -->
        </div>
      </div>
    </el-header>
    <el-main>
      <vote-analysis :id="questionnaire_id" v-if="show"></vote-analysis>
    </el-main>
  </el-container>
</template>

<script>
  import axios from "axios";
  import VoteAnalysis from "../components/Analysis/AnalysisPages/VoteAnalysis.vue";
  export default {
    components: {
      VoteAnalysis,
    },
    data() {
      return {
        questionnaire_id: null,
        show: false,
      };
    },
    async created() {
      this.questionnaire_id = this.$route.params.id;
      await axios
        .post("decode/", {
          questionnaire_id: this.questionnaire_id,
        })
        .then((response) => {
          if (response.data.code == -1) {
            this.$router.push({
              path: "/failure",
              query: {
                msg: "该问卷不存在或您没有权限访问",
              },
            });
          }
          this.questionnaire_id = response.data.id;
          this.show = true;
        });
    },
  };
</script>

<style scoped>
.buttons {
  margin-top: 10px;
  margin-right: 20px;
}
.buttons-header {
  display: flex;
  justify-content: space-between;
}
</style>